﻿
using Maticsoft.BLL;
using Maticsoft.DBUtility;
using Maticsoft.Model;
using System;
using System.Data;
using System.Text;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using Wuqi.Webdiyer;

public partial class WebPage_Index_XiangmuDabian : HelpBBasePage
{
    private Maticsoft.BLL.Ask ask = new Maticsoft.BLL.Ask();
    private string sql = " 1=1 ";
    private Maticsoft.BLL.Team team = new Maticsoft.BLL.Team();
    private int text = Convert.ToInt32(PageIndex.pageIndex);

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        this.HeaderControl1.Select = "index";
        if (base.Request.HttpMethod == "POST")
        {
            this.xiangmuDabiao();
        }
        if ((this.txttitle.Text != null) && (this.txttitle.Text != ""))
        {
            try
            {
                this.sql = this.sql + " and  Team_id=" + Convert.ToInt32(this.txttitle.Text);
            }
            catch (Exception)
            {
                this.SetError("对不起，您输入不正确，请重新输入!");
            }
        }
        if (!base.IsPostBack && ((base.Request["del"] != null) && (base.Request["del"].ToString() != "")))
        {
            this.ask.Delete(int.Parse(base.Request["del"].ToString()));
            base.SetSuccess("删除成功！");
            if ((base.Request.QueryString["pageIndex"] != null) && (base.Request.QueryString["pageIndex"].ToString() != ""))
            {
                this.pager.CurrentPageIndex = Convert.ToInt32(base.Request.QueryString["pageIndex"].ToString());
            }
            if ((base.Request.QueryString["where"] != null) && (base.Request.QueryString["where"].ToString() != ""))
            {
                this.sql = DESEncrypt.Decrypt(base.Request.QueryString["where"].ToString(), "type");
            }
        }
        this.xiangmuDabiao();
    }

    protected void pager_PageChanged(object sender, EventArgs e)
    {
        this.xiangmuDabiao();
    }

    private void xiangmuDabiao()
    {
        string sql = this.sql;
        StringBuilder builder = new StringBuilder();
        builder.Append("<tr >");
        builder.Append("<th width='260' style='height: 42px'>项目名称</th>");
        builder.Append("<th width='60' style='height: 42px'>咨询人</th>");
        builder.Append("<th width='200' style='height: 42px'>咨询</th>");
        builder.Append("<th width='200' style='height: 42px'>答复</th>");
        builder.Append("<th width='120' style='height: 42px'>操作</th>");
        builder.Append("</tr>");
        StringBuilder builder2 = new StringBuilder();
        Maticsoft.BLL.UserInfo info = new Maticsoft.BLL.UserInfo();
        int recordCount = 0;
        DataSet set = DbHelperSQL.Page(30, this.pager.CurrentPageIndex, "V_GetAsk", sql, "", "*", out recordCount);
        if ((set.Tables.Count > 0) && (set.Tables[0].Rows.Count > 0))
        {
            for (int i = 0; i < set.Tables[0].Rows.Count; i++)
            {
                DataRow row = set.Tables[0].Rows[i];
                if ((i % 2) != 0)
                {
                    builder2.Append("<tr>");
                }
                else
                {
                    builder2.Append("<tr class='alt'>");
                }
                foreach (Maticsoft.Model.Team team in this.team.GetModelList("Id=" + row["Team_id"].ToString()))
                {
                    builder2.Append("<td><a class=\"deal-title\" href=\"/team.aspx?id=" + row["Team_id"].ToString() + "\">" + team.Title + "</a></td>");
                }
                foreach (Maticsoft.Model.UserInfo info2 in info.GetModelList("Id=" + row["User_id"].ToString()))
                {
                    builder2.Append("<td nowrap>" + info2.Username + "</td>");
                }
                builder2.Append("<td><div style='overflow: hidden; width:200px;'>" + row["Content"].ToString() + "</div></td>");
                builder2.Append("<td>" + row["Comment"].ToString() + "</td>");
                builder2.Append(string.Concat(new object[] { "<td class=\"op\" nowrap><a href=\"/webpage/Index-XiangmuDabianEdit.aspx?id=", row["Id"].ToString(), "\">答复</a>｜<a href=\"Index-XiangmuDabian.aspx?del=", row["Id"].ToString(), "&pageIndex=", this.pager.CurrentPageIndex, "&where=", DESEncrypt.Encrypt(sql, "type"), "\" class=\"remove-record\">删除</a></td>" }));
                builder2.Append("</tr>");
            }
        }
        this.Literal1.Text = builder.ToString();
        this.Literal2.Text = builder2.ToString();
        this.pager.RecordCount = recordCount;
    }
}

